#include <iostream>
#include <iomanip>
#include "../head/Edge.h"
#include "../head/DenseGraph.h"
#include "../head/SparseGraph.h"
#include "../head/ReadGraph.h"
#include "../head/LazyPrim.h"
#include "../head/Prim.h"
#include "../head/Kruskal.h"

using namespace std;

void testWeight();
void testLazyPrim();

int main(){
	// testWeight();
	testLazyPrim();
	return 0;
}

// 分别用邻接矩阵和邻接表 描述带权图
void testWeight(){
	string filename = "testG1.txt";
	int V = 8;
	cout << fixed << setprecision(2);

	// Test Weighted Dense Graph
	DenseGraph<double> g1 = DenseGraph<double>(V, false);
	ReadGraph<DenseGraph<double>,double> readGraph1(g1, filename);
	g1.show();
	cout << endl;

	// Test Weighted Sparse Graph
	SparseGraph<double> g2 = SparseGraph<double>(V, false);
	ReadGraph<SparseGraph<double>,double> readGraph2(g2, filename);
	g2.show();
	cout << endl;
}

void testLazyPrim(){
	string filename = "testG1.txt";
	int V = 8;

	SparseGraph<double> g = SparseGraph<double>(V, false);
	ReadGraph<SparseGraph<double>, double> readGraph(g, filename);

	// test Lazy Prim MST
	cout<<"Test Lazy Prim MST:"<<endl;
	LazyPrimMST<SparseGraph<double>, double> lazyPrimMST(g);
	vector<Edge<double>> mst = lazyPrimMST.mstEdges();
	for( int i = 0 ; i < mst.size() ; i ++ )
		cout<<mst[i]<<endl;
	cout<<"The MST weight is: "<<lazyPrimMST.result()<<endl;

	// test Prim MST
	cout<<"Test Prim MST:"<<endl;
	PrimMST<SparseGraph<double>, double> PrimMST(g);
	mst = PrimMST.mstEdges();
	for( int i = 0 ; i < mst.size() ; i ++ )
		cout<<mst[i]<<endl;
	cout<<"The MST weight is: "<<PrimMST.result()<<endl;

	// test Kruskal MST
	cout<<"Test Kruskal MST:"<<endl;
	KruskalMST<SparseGraph<double>, double> kruskalMST(g);
	mst = kruskalMST.mstEdges();
	for( int i = 0 ; i < mst.size() ; i ++ )
		cout<<mst[i]<<endl;
	cout<<"The MST weight is: "<<kruskalMST.result()<<endl;

	cout << endl;
}
